<template>
  <el-dialog
    v-el-drag-dialog
    :title="!dataForm.id ? '新增' : '详情'"
    :close-on-click-modal="false"
    append-to-body
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
    <el-form-item label="编号:" prop="code">
      <el-input v-model="dataForm.code" placeholder="编号" style="width: 300px"></el-input>
    </el-form-item>
    <el-form-item label="优惠券发布类型:" prop="releaseType">
      <el-select v-model="dataForm.releaseType" placeholder="优惠券发布类型" style="width: 300px" @click="updateReleaseType()">
        <el-option label="平台赠券" value= 1></el-option>
        <el-option label="消费赠券" value= 2></el-option>
        <el-option label="签到赠券" value= 3></el-option>
        <el-option label="抽奖赠券" value= 4></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="赠券标准:" prop="couponStandard">
      <el-input v-if="this.dataForm.releaseType === '1' || this.dataForm.releaseType === '4'" v-model="dataForm.couponStandard" placeholder="赠券标准" disabled="true" style="width: 300px"></el-input>
      <span v-if="this.dataForm.releaseType === '2'" style="font-size: 18px">消费<el-input v-model="dataForm.couponStandard" style="width: 80px"></el-input>赠券</span>
      <span v-if="this.dataForm.releaseType === '3'" style="font-size: 18px">签到<el-input v-if="this.dataForm.releaseType === '3'" v-model="dataForm.couponStandard" style="width: 80px"></el-input>天赠券</span>
      <el-input v-if="this.dataForm.releaseType === '4'" v-model="dataForm.couponStandard" placeholder="抽奖赠券" disabled="true" style="width: 300px"></el-input>
    </el-form-item>
    <el-form-item label="优惠券名称:" prop="title">
      <el-input v-model="dataForm.title" placeholder="优惠券名称,限8字内" style="width: 300px" maxlength="8"></el-input>
    </el-form-item>
    <el-form-item label="优惠券描述:" prop="describe">
      <el-input v-model="dataForm.describe" placeholder="优惠券描述，限15字内" style="width: 300px" maxlength="15"></el-input>
    </el-form-item>
    <el-form-item label="优惠类型:" prop="discountType">
      <el-select v-model="dataForm.discountType" placeholder="优惠类型" style="width: 300px" @change="updatediscountType()">
        <el-option label="固定金额" value= 1></el-option>
        <!-- <el-option label="折扣" value= 2></el-option> -->
      </el-select>
    </el-form-item>
    <el-row :gutter="20">
      <el-col span="7">
        <el-form-item :label="this.dataForm.discountType === '1' ? '面额:' : '折扣:'" prop="full">
          <span v-if="this.dataForm.discountType === '1'" style="font-size: 18px">满<el-input v-model="dataForm.full" style="width: 80px"></el-input>元</span>
          <!-- <span v-if="this.dataForm.discountType === '2'" style="font-size: 18px">满<el-input v-model="dataForm.full" style="width: 80px"></el-input>件</span> -->
        </el-form-item>
      </el-col>
      <el-col span="7">
        <el-form-item :label="this.dataForm.discountType === '1' ? '优惠金额:' : '折扣优惠:'" prop="reduce">
          <span v-if="this.dataForm.discountType === '1'" style="font-size: 18px">减<el-input v-model="dataForm.reduce" style="width: 80px"></el-input>元</span>
          <!-- <span v-if="this.dataForm.discountType === '2'" style="font-size: 18px">
            <el-select v-model="dataForm.reduce" filterable  placeholder="请选择" >
            <span v-for="i in 9" :key="i">
              <el-option
                v-for="(j,index) in 10"
                :key="i+'.'+index"
                :label="i+'.'+index +' 折'"
                :value="i+'.'+index">
              </el-option>
            </span>
            <el-option :key="9.9" label="9.9 折" :value="9.9"></el-option>
          </el-select></span> -->
        </el-form-item>
      </el-col>
    </el-row>
    <el-form-item label="发放人群:" prop="intendedFor">
      <el-select v-model="dataForm.intendedFor" placeholder="发放人群" style="width: 300px">
        <el-option label="所有会员" value= 1></el-option>
        <el-option label="新人专享" value= 2></el-option>
        <el-option label="普通会员+VIP" value= 3></el-option>
        <el-option label="普中高级联盟店" value= 4></el-option>
        <el-option label="城市合伙人" value= 5></el-option>
        <el-option label="运营商" value= 6></el-option>
      </el-select>
      <!-- <el-input v-model="dataForm.intendedFor" placeholder="适用人群：1全部用户 2新人专享 3会员 4联盟店 5合伙人 6运营商"></el-input> -->
    </el-form-item>
    <el-form-item label="有效期:" prop="termType">
      <el-radio v-model="dataForm.termType" label="1" @change="termType(1)" v-if="this.dataForm.releaseType != '4'">日期范围</el-radio>
      <el-radio v-model="dataForm.termType" label="2" @change="termType(2)">固定天数</el-radio>
    </el-form-item>
    <el-row :gutter="20" v-if="this.dataForm.termType === '1' && this.dataForm.releaseType != '4'">
      <el-col span="10">
        <el-form-item label="开始时间:" prop="startTime">
          <el-date-picker
          v-model="dataForm.startTime"
          type="date"
          placeholder="开始时间"
          disabled="true"
          format="yyyy 年 MM 月 dd 日">
          </el-date-picker>
        </el-form-item>
      </el-col>
      <el-col span="10">
        <el-form-item label="结束时间:" prop="endTime">
          <el-date-picker
          v-model="dataForm.endTime"
          type="date"
          placeholder="结束时间"
          format="yyyy 年 MM 月 dd 日"
          :picker-options="pickerOptions">
          </el-date-picker>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20" v-if="this.dataForm.termType === '2'">
      <el-col span="10">
        <el-form-item label="有效天数:" prop="effectiveDays">
          <el-input v-model="dataForm.effectiveDays" style="width: 80px"></el-input><span style="font-size: 18px">天</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-form-item label="发行量:" prop="circulationType">
      <!-- <el-radio v-model="dataForm.circulationType" label="2" @change="circulationType()">不限量</el-radio>
      <el-radio v-model="dataForm.circulationType" label="1">限量</el-radio>&nbsp;&nbsp;<span style="font-size: 18px" v-if="this.dataForm.circulationType === '1'"><el-input v-model="dataForm.circulation" style="width: 80px"></el-input>张</span> -->
      <span style="font-size: 18px"><el-input type="number" v-model="dataForm.circulation" style="width: 80px"></el-input>张</span>
    </el-form-item>
    <el-row :gutter="20" v-if="this.dataForm.id">
      <el-col span="7">
        <el-form-item label="已领数量:" prop="alreadyLedNumber">
          <el-input v-model="dataForm.alreadyLedNumber" placeholder="已领" style="width: 80px"></el-input>
        </el-form-item>
      </el-col>
      <el-col span="6">
        <el-form-item label="剩余库存:" prop="stock">
          <el-input v-model="dataForm.stock" placeholder="库存" style="width: 80px"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col>
        <el-form-item label="限领数量:" prop="limitCollarNumber">
          <el-radio v-model="dataForm.limitCollarNumberType" @change="limitCollarNumber()" label="0">不限量</el-radio>
          <el-radio v-model="dataForm.limitCollarNumberType" label="1" @change="limitCollarNumber1()">限量</el-radio>&nbsp;&nbsp;<span style="font-size: 18px" v-if="this.dataForm.limitCollarNumberType === '1'"><el-input v-model="dataForm.limitCollarNumber" style="width: 80px"></el-input>张</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col>
        <el-form-item label="适用范围:" prop="scopeOfApplication">
          <el-radio v-model="dataForm.scopeOfApplication" label="1" @change="queryClass(1)">全品类券</el-radio>
          <el-radio v-model="dataForm.scopeOfApplication" label="2" @change="queryClass(2)">分类</el-radio>
          <el-radio v-model="dataForm.scopeOfApplication" label="3" @change="queryClass(3)">专题</el-radio>
          <el-radio v-model="dataForm.scopeOfApplication" label="4" @change="queryClass(4)">单品</el-radio>
        </el-form-item>
      </el-col>
      <el-col>
        <el-form-item v-if="this.dataForm.scopeOfApplication === '2' || this.dataForm.scopeOfApplication === '3'" :label="this.dataForm.scopeOfApplication === '2' ? '选择分类' : '选择专题'">
          <el-cascader v-model="dataForm.classId" :options="classList" :props="props" expand-trigger="hover" filterable></el-cascader>
          <!-- <el-cascader
    placeholder="试试搜索：指南"
    :options="this.classList"
    filterable
  ></el-cascader> -->
          <!-- <el-select v-model="dataForm.applicableSourcesId" style="width: 300px">
            <el-option
              v-for="item in this.classList"
              :key="item.className"
              :label="item.className"
              :value="item.id">
            </el-option>
          </el-select> -->
        </el-form-item>
      </el-col>
      <el-col :span="5" v-for="(item, index) in goodsList" :key="index" style="padding-bottom: 20px;margin-left: 50px">
        <el-card :body-style="{ padding: '0px' }" class="el-card is-hover-shadow">
          <img :src="item.img" class="image">
          <div style="padding: 14px;">
            <span class="characters">{{item.goodsName}}</span><br/>
            <span>商城售价：{{item.vipPrice}}</span><br/>
            <span>积分价：{{item.integral}}</span>
            <div class="bottom clearfix">
              <el-button type="text" style="float: right" @click="deleteGoods(index, true)">删除</el-button>
            </div>
          </div>
        </el-card>
      </el-col>
      <span v-if="dataForm.scopeOfApplication === '2' || dataForm.scopeOfApplication === '3'">
        <el-button type="primary" @click="forward()" style="margin: auto;display: inline-block;margin-left: 50px" v-if="this.goodsList.length < 3 && this.dataForm.classId.length >= 0">添加商品</el-button>
      </span>
      <span>
        <el-button type="primary" @click="forward()" style="margin: auto;display: inline-block;margin-left: 50px" v-if="this.goodsList.length < 1 && dataForm.scopeOfApplication === '4'">添加商品</el-button>
      </span>
    </el-row>
    <!-- <el-form-item label="适用来源ID（全品类默认1，分类/专题/单品关联Id）" prop="applicableSourcesId">
      <el-input v-model="dataForm.applicableSourcesId" placeholder="适用来源ID（全品类默认1，分类/专题/单品关联Id）"></el-input>
    </el-form-item> -->
    <!-- <el-form-item label="商品信息json" prop="goodsJson">
      <el-input v-model="dataForm.goodsJson" placeholder="商品信息json"></el-input>
    </el-form-item> -->
    <el-form-item label="备注信息:" prop="remarks">
      <el-input type="textarea" v-model="dataForm.remarks" placeholder="备注信息" style="width: 300px"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer" v-if="!this.dataForm.id">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
    <add-coupon-goods v-if="addOrUpdateVisible" ref="addCouponGoods" @info="addSelectGoods"></add-coupon-goods>
  </el-dialog>

  <!-- <add-coupon-goods v-if="dialogVisible" ref="addCouponGoods" @refreshDataList="init" @info="addSelectSpecs" ></add-coupon-goods> -->
</template>

<script>
  import AddCouponGoods from './add-coupon-goods'
  export default {
    data () {
      var checkDecimal = (rule, value, callback) => {
        if (typeof value === 'object' || value === undefined) {
          value = rule.field
        }
        let reg = /^[0-9]*[1-9][0-9]*$/
        if (Number.parseInt(value) < 0 || !reg.test(value) || Number.parseInt(value) > 10000) {
          callback(this.$message.error('只能输入0-10000，整数数字！'))
        } else {
          callback()
        }
      }
      var checkReduce = (rule, value, callback) => {
        debugger
        if (this.dataForm.discountType === '1') {
          if (typeof value === 'object' || value === undefined) {
            value = rule.field
          }

          if (Number.parseInt(value) !== 1 && Number.parseInt(value) % 5 !== 0 && Number.parseInt(value) !== 3 && Number.parseInt(value) !== 5) {
            callback(this.$message.error('只能输入1，3，5，5的整数倍数！'))
          } else {
            callback()
          }
        }
      }
      var checkInteger1 = (rule, value, callback) => {
        debugger
        if (this.dataForm.releaseType !== '1') {
          if (typeof value === 'object' || value === undefined) {
            value = rule.field
          }
          let reg = /^[1-9]\d*$/
          if (!reg.test(value)) {
            callback(this.$message.error('只能输入大于0整数！'))
          } else {
            callback()
          }
        } else {
          callback()
        }
      }
      var checkInteger = (rule, value, callback) => {
        if (typeof value === 'object' || value === undefined) {
          value = rule.field
        }
        let reg = /^[1-9]\d*$/
        if (!reg.test(value)) {
          callback(this.$message.error('只能输入大于0整数！'))
        } else {
          callback()
        }
      }
      return {
        addOrUpdateVisible: false,
        props: {
          value: 'id',
          label: 'className',
          children: 'subGoodsClassList'
        },
        visible: false,
        classList: [],
        goodsList: [],
        dataForm: {
          id: 0,
          code: '',
          releaseType: '1',
          couponStandard: '',
          wayOfReceiving: '',
          title: '',
          describe: '',
          discountType: '1',
          full: 0,
          reduce: '',
          intendedFor: '1',
          termType: '1',
          startTime: new Date(),
          endTime: '',
          effectiveDays: 0,
          circulationType: '1', // 发行量类型
          circulation: 0,
          limitCollarNumberType: '0', // 限领类型
          alreadyLedNumber: '',
          stock: '',
          limitCollarNumber: 0,
          scopeOfApplication: '1',
          applicableSourcesId: 1,
          classId: [],
          goodsJson: '',
          remarks: ''
        },
        dataRule: {
          code: [
            { required: true, message: '编号不能为空', trigger: 'blur' }
          ],
          couponStandard: [
            { validator: checkInteger1, required: true, trigger: 'blur' }
          ],
          title: [
            { required: true, message: '优惠券名称不能为空', trigger: 'blur' }
          ],
          describe: [
            { required: true, message: '优惠券描述不能为空', trigger: 'blur' }
          ],
          full: [
            { validator: checkDecimal, required: true, trigger: 'blur' }
          ],
          reduce: [
            { validator: checkReduce, required: true, trigger: 'blur' }
          ],
          effectiveDays: [
            { validator: checkInteger, required: true, trigger: 'blur' }
          ],
          circulation: [
            { validator: checkInteger, required: true, trigger: 'blur' }
          ],
          limitCollarNumber: [
            { validator: checkInteger, required: true, trigger: 'blur' }
          ]
        },
        pickerOptions: {
          disabledDate (time) {
            // 如果没有后面的-8.64e7就是不可以选择今天的
            return time.getTime() < Date.now()
          }
        }
      }
    },
    components: {
      AddCouponGoods
    },
    methods: {
      addSelectGoods: function (info) {
        this.goodsList = info
      },
      init (id) {
        this.goodsList = []
        if (id) {
          this.$message.error('优惠券暂不可修改！')
        }
        this.$http({
          url: this.$http.adornUrl(`/shopping/coupon/queryClass/4`),
          method: 'get',
          params: this.$http.adornParams()
        }).then(({data}) => {
          if (data && data.code === 0) {
            debugger
            this.classList = data.data
          }
        })
        this.goodsList = []
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/shopping/coupon/getCouponInfoById/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.code = data.data.code
                this.dataForm.releaseType = data.data.releaseType + ''
                this.dataForm.couponStandard = data.data.couponStandard
                this.dataForm.wayOfReceiving = data.data.wayOfReceiving
                this.dataForm.title = data.data.title
                this.dataForm.describe = data.data.describe
                this.dataForm.discountType = data.data.discountType + ''
                this.dataForm.full = data.data.full
                this.dataForm.reduce = data.data.reduce
                this.dataForm.intendedFor = data.data.intendedFor + ''
                this.dataForm.startTime = data.data.startTime
                this.dataForm.endTime = data.data.endTime
                this.dataForm.termType = data.data.termType + ''
                this.dataForm.effectiveDays = data.data.effectiveDays
                this.dataForm.circulation = data.data.circulation
                this.dataForm.alreadyLedNumber = data.data.alreadyLedNumber
                this.dataForm.stock = data.data.stock
                this.dataForm.limitCollarNumber = data.data.limitCollarNumber
                if (data.data.limitCollarNumber !== 0) {
                  this.dataForm.limitCollarNumberType = '1'
                }
                this.dataForm.scopeOfApplication = data.data.scopeOfApplication + ''
                debugger
                if (data.data.scopeOfApplication === 2) {
                  // this.$http({
                  //   url: this.$http.adornUrl(`/shopping/coupon/queryClass/${data.data.scopeOfApplication}`),
                  //   method: 'get',
                  //   params: this.$http.adornParams()
                  // }).then(({data}) => {
                  //   if (data && data.code === 0) {
                  //     this.classList = data.data
                  //   }
                  // })
                  this.$http({
                    url: this.$http.adornUrl(`/activity/goods/queryClassList`),
                    method: 'get',
                    params: this.$http.adornParams()
                  }).then(({data}) => {
                    if (data && data.code === 0) {
                      this.classList = data.data
                      debugger
                    }
                  })
                } else if (data.data.scopeOfApplication === 3) {
                  this.$http({
                    url: this.$http.adornUrl(`/shopping/coupon/queryClass/${data.data.scopeOfApplication}`),
                    method: 'get',
                    params: this.$http.adornParams()
                  }).then(({data}) => {
                    if (data && data.code === 0) {
                      this.classList = data.data
                    }
                  })
                }
                this.dataForm.applicableSourcesId = data.data.applicableSourcesId
                this.goodsList = JSON.parse(data.data.goodsJson)
                this.dataForm.remarks = data.data.remarks
                // if (data.data.circulation === 0) {
                //   this.dataForm.circulationType = 2 + ''
                // } else if (data.data.circulation > 0) {
                //   this.dataForm.circulationType = 1 + ''
                // }
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        if (this.dataForm.scopeOfApplication === '2' || this.dataForm.scopeOfApplication === '3') {
          if (this.goodsList.length !== 3) {
            this.$message.error('适用范围为分类和专题的商品必须为3个！')
            return
          }
        }
        if (this.dataForm.scopeOfApplication === '4') {
          if (this.goodsList.length !== 1) {
            this.$message.error('适用范围为单品的商品最多（至少）1个！')
            return
          }
          this.dataForm.applicableSourcesId = this.goodsList[0].id
        }
        if (this.dataForm.full !== null) {
          let reg = /^[0-9]*[1-9][0-9]*$/
          if (Number.parseInt(this.dataForm.full) < 0 || !reg.test(this.dataForm.full) || Number.parseInt(this.dataForm.full) > 10000) {
            this.$message.error('只能输入0-10000，整数数字！')
            return
          }
        }
        if (this.dataForm.reduce !== '') {
          if (this.dataForm.discountType === '1') {
            if (Number.parseInt(this.dataForm.reduce) !== 1 && Number.parseInt(this.dataForm.reduce) % 5 !== 0 && Number.parseInt(this.dataForm.reduce) !== 3 && Number.parseInt(this.dataForm.reduce) !== 5) {
              this.$message.error('只能输入1，3，5，5的整数倍数！')
              return
            }
          }
        }
        if (Number.parseInt(this.dataForm.full) <= Number.parseInt(this.dataForm.reduce)) {
          this.$message.error('面额不能小于等于满减金额！')
          return
        }
        if (this.dataForm.couponStandard !== '') {
          if (this.dataForm.releaseType !== '1') {
            let reg = /^[1-9]\d*$/
            if (!reg.test(this.dataForm.couponStandard)) {
              this.$message.error('只能输入大于0整数！')
              return
            }
          }
        }
        if (this.dataForm.termType === '1' && this.dataForm.endTime === '') {
          this.$message.error('时间范围必须选择时间！')
          return
        }
        if (this.dataForm.scopeOfApplication === '1') {
          this.dataForm.applicableSourcesId = 1
        } else if (this.dataForm.scopeOfApplication === '2') {
          this.dataForm.applicableSourcesId = this.dataForm.classId[1]
        } else if (this.dataForm.applicableSourcesId === '3') {
          this.dataForm.applicableSourcesId = this.dataForm.classId[0]
        }
        // if (this.dataForm.effectiveDays !== 0 || this.dataForm.circulation !== 0 || this.dataForm.limitCollarNumber !== 1) {
        //   let reg = /^[1-9]\d*$/
        //   if (!reg.test(this.dataForm.effectiveDays) || !reg.test(this.dataForm.circulation) || !reg.test(this.dataForm.effectilimitCollarNumberveDays)) {
        //     this.$message.error('只能输入大于0整数！')
        //     return
        //   }
        // }
        // this.$refs['dataForm'].validate((valid) => {
          debugger
          // if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/shopping/coupon/${!this.dataForm.id ? 'addCoupon' : 'modifyCouponById'}`),
              method: 'post',
              data: this.$http.adornData({
                'id': this.dataForm.id || undefined,
                'code': this.dataForm.code,
                'releaseType': this.dataForm.releaseType,
                'couponStandard': this.dataForm.couponStandard,
                'wayOfReceiving': this.dataForm.wayOfReceiving,
                'title': this.dataForm.title,
                'describe': this.dataForm.describe,
                'discountType': this.dataForm.discountType,
                'full': this.dataForm.full,
                'reduce': this.dataForm.reduce,
                'intendedFor': this.dataForm.intendedFor,
                'startTime': this.dataForm.startTime,
                'endTime': this.dataForm.endTime,
                'effectiveDays': this.dataForm.effectiveDays,
                'circulation': this.dataForm.circulation,
                'alreadyLedNumber': this.dataForm.alreadyLedNumber,
                'stock': this.dataForm.stock,
                'limitCollarNumber': this.dataForm.limitCollarNumber,
                'scopeOfApplication': this.dataForm.scopeOfApplication,
                'applicableSourcesId': this.dataForm.applicableSourcesId,
                'goodsJson': JSON.stringify(this.goodsList),
                'remarks': this.dataForm.remarks,
                'termType': this.dataForm.termType
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
        //   }
        // })
      },
      forward () {
        if (this.dataForm.scopeOfApplication === '2' || this.dataForm.scopeOfApplication === '3') {
          if (this.goodsList.length >= 3) {
            this.$message.error('最多只能选择三个商品！')
            return
          }
        }
        if(this.dataForm.scopeOfApplication === '4' && this.goodsList.length >= 1) {
          debugger
          this.$message.error('单品最多只能有一个商品！')
          return
        }
        let id = 0
        debugger
        if (this.dataForm.scopeOfApplication === '2') {
          id = this.dataForm.classId[1]
        } else {
          id = this.dataForm.classId[0]
        }
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addCouponGoods.init(this.dataForm.scopeOfApplication, id, this.goodsList)
        })
      },
      // 移除商品
      deleteGoods (index) {
        this.goodsList.splice(index, 1)
      },
      // 更换发布类型时重制赠券标准
      updateReleaseType () {
        this.dataForm.couponStandard = ''
      },
      // 更换优惠类型重置使用门槛
      updatediscountType () {
        this.dataForm.full = 0
        this.dataForm.reduce = ''
      },
      limitCollarNumber () {
        this.dataForm.limitCollarNumber = 0
      },
      limitCollarNumber1 () {
        this.dataForm.limitCollarNumber = 1
      },
      termType (type) {
        if (type === 1 || type === 4) {
          this.dataForm.effectiveDays = 0
        } else {
          this.dataForm.startTime = null
          this.dataForm.endTime = null
        }
      },
      circulationType () {
        this.dataForm.circulation = 0
      },
      discountType () {
        this.dataForm.full = 0
        this.dataForm.reduce = ''
      },
      // 请求分类信息
      queryClass (type) {
        this.dataForm.applicableSourcesId = ''
        if (type === 1) {
          this.dataForm.scopeOfApplication = '1'
          this.dataForm.applicableSourcesId = 1
        }
        this.goodsList = []
        debugger
        if (type === 2) {
          this.$http({
            url: this.$http.adornUrl(`/activity/goods/queryClassList`),
            method: 'get',
            params: this.$http.adornParams()
          }).then(({data}) => {
            if (data && data.code === 0) {
              debugger
              this.classList = data.data
            }
          })
        } else {
          this.$http({
            url: this.$http.adornUrl(`/shopping/coupon/queryClass/${type}`),
            method: 'get',
            params: this.$http.adornParams()
          }).then(({data}) => {
            if (data && data.code === 0) {
              debugger
              this.classList = data.data
            }
          })
        }
      }
    }
  }
</script>
<style>
.time {
    font-size: 13px;
    color: #999;
  }

  .bottom {
    margin-top: 13px;
    line-height: 12px;
  }

  .button {
    padding: 0;
    float: right;
  }

  .image {
    width: 100%;
    display: block;
    height: 100px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }

  .clearfix:after {
    clear: both
  }

  .sku img{
    max-width: 80px;
  }

  .sku {
    display: -webkit-box;
  }
  .sku s{
    font-size: 10px;
    color: #b5b2b2;
    padding-left: 15px;
  }

  .sku .sub-title{
    color: #b5b2b2;
    font-size: 10px;
  }
  .specs{
    padding-top: 20px;
  }
  .sku .price{
    padding-left: 10px;
  }
  .el-badge__content{
    margin-right: 60px;
  }
  .el-badge__content.is-fixed {
    right: 0px !important;
  }
</style>

